<script type="text/javascript">
 var subject=new Array(4);
 var subject_id=new Array(4);
 subject[0]=new Array();
 subject[1]=new Array();
 subject[2]=new Array();
 subject_id[0]=new Array();
 subject_id[1]=new Array();
 subject_id[2]=new Array();

   <?php
    $ind_s=0;
    $ind_a=0;
    $ind_c=0;
	 foreach($code_subject as $row)
		{
		    if($row["group_id"]=="Science")
		     {?>
			    subject[0][<?php echo $ind_s ; ?>]= '<?php echo $row["subject_name"]; ?>';
			    subject_id[0][<?php echo $ind_s ; ?>]= '<?php echo $row["subject_id"]; ?>';
			     
		<?php $ind_s=$ind_s+1;
            }
	      }	?>
	      <?php
	      foreach($code_subject as $row)
			{
			    if($row["group_id"]=="Humanities")
			     {?>
				    subject[1][<?php echo $ind_a ; ?>]= '<?php echo $row["subject_name"]; ?>';
				    subject_id[1][<?php echo $ind_a ; ?>]= '<?php echo $row["subject_id"]; ?>';
				     
			<?php $ind_a=$ind_a+1;
	            }
		      }	?> 
		      <?php
		    	 foreach($code_subject as $row)
		    	  {
		    		  if($row["group_id"]=="Business Studies")
		    		     {?>
		    			    subject[2][<?php echo $ind_c ; ?>]= '<?php echo $row["subject_name"]; ?>';
		    			    subject_id[2][<?php echo $ind_c ; ?>]= '<?php echo $row["subject_id"]; ?>';
		    				     
		    <?php $ind_c=$ind_c+1;
		    	  }
		    }	?>    
	function com_subject_id()
	    {
		 var myOpt=document.getElementById("subject_id");
		 var group_id=document.getElementById("group_id").value;
		 myOpt.length=0;
		 var k=0;
		  if(group_id=="Science")
		  {
			  for(var i=0;i<subject[0].length;i++)
		        myOpt.options[k++] = new Option(subject[0][i],subject_id[0][i]);
		  }
		  if(group_id=="Humanities")
		  {
			  for(var i=0;i<subject[1].length;i++)
		        myOpt.options[k++] = new Option(subject[1][i],subject_id[1][i]);
		  }
		  if(group_id=="Business Studies")
		  {
			  for(var i=0;i<subject[2].length;i++)
		        myOpt.options[k++] = new Option(subject[2][i],subject_id[2][i]);
		  }
		}

	////////////////////////////////////////////////////////////////////////////
	function expandingWindow(website) {
		var windowprops='width=100,height=100,scrollbars=yes,status=yes,resizable=yes'
		var heightspeed = 15; // vertical scrolling speed (higher = slower)
		var widthspeed = 20;  // horizontal scrolling speed (higher = slower)
		var leftdist = 60;    // distance to left edge of window
		var topdist = 60;     // distance to top edge of window

		if (window.resizeTo&&navigator.userAgent.indexOf("Opera")==-1) {
		var winwidth = window.screen.availWidth - leftdist-leftdist;
		var winheight = window.screen.availHeight - topdist;
		var sizer = window.open("","","left=" + leftdist + ",top=" + topdist +","+ windowprops);

		for (sizeheight = 1; sizeheight < winheight; sizeheight += heightspeed)
			sizer.resizeTo("1", sizeheight);
		for (sizewidth = 1; sizewidth < winwidth; sizewidth += widthspeed)
			sizer.resizeTo(sizewidth, sizeheight);
			
		sizer.location = website;
		}
		else
		window.open(website,'mywindow');
		}
	//////////////////////////////////////////////////////////////////////
	function popUpWindow() {
	    var academic_session=document.getElementById('academic_session').value;
	    var group_id=document.getElementById('group_id').value;
	    var url = "<?php echo base_url(); ?>index.php?/admin/get_all_student/"+academic_session+"/"+group_id;
	    //var win = window.open(url,'MyWindow','width=620,height=200');
	    //popwin.focus();    
	   expandingWindow(url);
	}
	function insertStudents(student_id)
	{
		document.getElementById('area_student_id').value=student_id;
	}
	/////////////////////////////////////////////////////////////////////////////	    
</script>

		<ul class="breadcrumb"><span style="font-size:14px;font-weight:bold;">Assign Core or Optional Subject</span> </ul>
		    
<div id="opt_subject_html"  align="center">
<form id="opt_sub_form">
<div>Session: <?php echo $academic_session;?>
<input type="hidden" id="academic_session" name="academic_session" value="<?php echo $academic_session;?>" ></div>
<table style="text-align: left;width: 40%" align="center" border="0">
  
  <tr>
    <td>
   Group Type
    </td>
    <td> 
         <select id="group_id" name="group_id" onchange="com_subject_id()">
           <option value="Science">Science</option>
           <option value="Humanities">Humanities</option>
           <option value="Business Studies">Business Studies</option>
           <option value="" selected="selected">Please Select</option>
         </select>
    </td>
  </tr>
  <tr>
    <td>
     Subject Name
    </td>
    <td> 
         <select id="subject_id" name="subject_id">
           
         </select>
    </td>
    </tr>
    <tr>
    <td>
     Subject Type
    </td>
    <td> 
         <select id="subject_type" name="subject_type">
           <option value="core_subj">Core Subject</option>
           <option value="opt_subj">Optional Subject</option>
         </select>
    </td>
    </tr>
     <tr>
    <td>
     Student Roll No.
    </td>
    <td> 
         <div style="left"><textarea id="area_student_id" name="area_student_id" rows="5" cols="55"></textarea></div>
         <div style="float: right;">
         <input type="button" name="" id="" class="btn btn-primary" value="Add Student" onclick="popUpWindow()"></div>
    </td>
  </tr>
</table>
  <div>
   <input type="submit" value="Assign  subject for Student" id="assign_subject" onclick="insert_std_assign_optional_core_subject()" class="btn btn-info">
  </div>
  </form>
</div>

	    <div onMouseUp="return false" class="translucent" onMouseMove="return false" onMouseDown="return false"
                                                                id="blockDim" onDblClick="return false" style="DISPLAY: none; Z-INDEX: 50000; LEFT: 0px; POSITION: absolute; TOP: 0px; BACKGROUND-COLOR: #FFFFFF;border: 1px solid black;text-align: center;"
                                                                onclick="return false" >
           <img src="<?php echo base_url(); ?>assets/img/ajax-loader5.gif" id="imagePosition">
           <div id="loading" style="font-size: 20px;font-weight: bold"></div>                                                             
         </div>